<?php $in_row = $this->config->product_count_related_in_row;?>
<?php if (count($this->related_prod)){?>
    
    <h3 class="jshop-titleheading-2"><?php print _JSHOP_RELATED_PRODUCTS?></h3>
    <div class="jshop realted-products">
    	 <?php foreach($this->related_prod as $k=>$product){?>
         <?php if ($k%$in_row==0) print "<div class='product_row clearfix'>";?>
         	
            <?php
	          if( ($k+1)%$in_row == 1 ) {
	            $divpos = " block-first";
	          } elseif ( ($k+1)%$in_row == 0) {
	            $divpos =" block-last";
	          } else { $divpos=""; }
	        ?>
            
            <div style="width: <?php print 100/$in_row?>%" class = "jshop_categ jshop_related<?php echo $divpos; ?>">
          		<div class="product">                
                <div class="name">
                    <a href="<?php print $product->product_link?>"><?php print $product->name?></a>
                </div>
                <div class="product-image">
                    <a href="<?php print $product->product_link?>">
                        <img class = "jshop_img" src = "<?php print $this->image_product_path?>/<?php if ($product->product_thumb_image) print $product->product_thumb_image; else print $this->noimage?>" alt="<?php print htmlspecialchars($product->name)?>" />
                    </a>
                </div>
                <div class="jshop_price">
                <?php if ($product->product_price > 0 || !$this->config->user_as_catalog){?>
                    <span><?php if ($product->show_price_from) print _JSHOP_FROM." ";?><?php print formatprice($product->product_price);?></span>
                <?php }?>
               </div>
               </div>
            
            </div>
           <?php if ($k%$in_row==$in_row-1) print "</div>";?> 
             <?php }?>
   <?php if ($k%$in_row!=$in_row-1) print "</div>";?>
    </div>
    
     <script type="text/javascript">
    window.addEvent('load', function(){
        var items = $$('.realted-products .product');
        var max_height = 0;
        var i, h = 0;
        var l = items.length;
        // Get max height 
        for (var i = 0; i < l; i++){
            h = items[i].getHeight();
            if (max_height < h) {
                max_height = h;
            }
        }
        // Set max height
        for (i = 0; i < l; i++) {
            items[i].setStyle('min-height', max_height);
        }
    });
  </script>
    
    
<?php }?>